<template>
  <div>
    <br />
    <br />
    <br />
    <br />
    <br />
    <h2 class="text-primary">感谢您的参与</h2>
    <h4 class="text-muted" v-show="(postResult==-1)">请稍等，提交数据ing...</h4>
    <h4 class="text-muted" v-show="(postResult==0)">数据已提交！</h4>
    <h4 class="text-muted" v-show="(postResult==1)">您已参加过，此次结果不会记录</h4>
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <h6 class="text-muted">民航西南地区空中交通管理局</h6>
    <h6 class="text-muted">2019.12</h6>
    <br />
    <br />
    <p style="color:lightgrey;font-size:0.8em">成都终端管制室 创新工作室 2021</p>
  </div>
</template>

<script>
export default {
  name: "EndView",
  data() {
    return {
      postResult: -1
    };
  },
  computed: {
    devMode() {
      return this.$store.state.devMode;
    },
    usrinfo() {
      return this.$store.state.userInfo;
    },
    holland() {
      return this.$store.state.hollandData.scoreData;
    },
    belbin() {
      return this.$store.state.belbinScore;
    },
    postData() {
      return {
        usrinfo: this.usrinfo,
        belbin: this.belbin,
        holland: this.holland
      };
    },
    postDataString() {
      return JSON.stringify(this.postData);
    }
  },
  methods: {
    post() {
      this.axios
        .post("backend.php", {
          action: "upload",
          payload: this.postData
        })
        .then(response => {
          window.console.log(response);
          this.postResult = response.data;
        })
        .catch(error => {
          window.console.log(error);
        });
    }
  },
  mounted() {
    if (this.devMode) {
      window.console.clear();
      window.console.log(this.postDataString);
    }
    this.post();
  }
};
</script>

<style scoped>
.code {
  text-align: start;
}
</style>